module.exports = options => {
  return async (ctx, next) => {
    await next().catch((error) => {
      ctx.status = error.status || 500
      ctx.body = {
        message: error.message,
      }
    })
  }
}